[jquery] e.which code for escape key
Posted
by Shishant
on Stack Overflow
See other posts from Stack Overflow
or by Shishant
Published on 2009-07-21T15:39:25Z
Indexed on
2010/05/12
3:34 UTC
Read the original article
Hit count: 190
jQuery
|JavaScript
I have two functions. When enter is pressed the functions runs correctly but when escape is pressed it doesn't. What's the correct number for the escape key?
$(document).keypress(function(e) {
if (e.which == 13) { $('.save').click(); } // enter (works as expected)
if (e.which == 27) { $('.cancel').click(); } // esc (does not work)
});
© Stack Overflow or respective owner